package com.bruip.reggie.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bruip.reggie.common.BaseResponse;
import com.bruip.reggie.dto.OrdersDto;
import com.bruip.reggie.pojo.OrderDetail;
import com.bruip.reggie.pojo.Orders;
import com.bruip.reggie.service.OrdersService;
import com.bruip.reggie.util.BaseContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * @author 王若龙
 * @date 2022-10-12 13:00
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrdersController {

    @Autowired
    private OrdersService ordersService;

    @PostMapping("/submit")
    public BaseResponse<String> submit(@RequestBody Orders orders){
        ordersService.submit(orders);
        return BaseResponse.success("下单成功");
    }

    @GetMapping("/userPage")
    public BaseResponse<Page> userPage(Integer page, Integer pageSize){
        Page<OrdersDto> ordersDtoPage = ordersService.userPage(page, pageSize);
        return BaseResponse.success(ordersDtoPage);
    }

}
